package com.xingqing.repository;

import com.xingqing.domain.entity.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {
    
    @Select("SELECT * FROM dept ORDER BY create_time DESC")
    List<Dept> selectAll();
    
    @Select("SELECT * FROM dept WHERE id = #{id}")
    Dept selectById(Long id);
    
    @Insert("INSERT INTO dept (name, create_time, update_time) VALUES (#{name}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Dept dept);
    
    @Update("UPDATE dept SET name = #{name}, update_time = #{updateTime} WHERE id = #{id}")
    void updateById(Dept dept);
    
    @Delete("DELETE FROM dept WHERE id = #{id}")
    void deleteById(Long id);
}